package com.company;

import java.util.ArrayList;

/**
 * @description:
 * @author: 10445
 * @date: Created in 2020/6/12 23:18
 * @version: v1.0
 * @modified By:
 */
public class Room {
    private String description;
    private Room northExit;
    private Room southExit;
    private Room eastExit;
    private Room westExit;
    private Room northwestExit;
    private Room southwestExit;
    private Room northeastExit;
    private Room southeastExit;
    private Room upExit;
    private Room downExit;

    private ArrayList<MonsterWolf> monsterWolves = new ArrayList<>();

    public Room(String description)
    {
        this.description = description;
    }

    //set Monster
    public void setMonsterWolves(ArrayList<MonsterWolf> monsterWolves){
        this.monsterWolves = monsterWolves;
    }

    public void setExits(Room north, Room east, Room south, Room west,Room northwest,Room southeast,Room northeast,Room southwest,Room up,Room down)
    {
        if(north != null)
            northExit = north;
        if(east != null)
            eastExit = east;
        if(south != null)
            southExit = south;
        if(west != null)
            westExit = west;
        if(northwest != null)
            northwestExit = northwest;
        if(northeast != null)
            northeastExit = northeast;
        if(southwest != null)
            southwestExit = southwest;
        if(southeast != null)
            southeastExit = southeast;
        if (up !=null)
            upExit = up;
        if (down !=null)
            downExit = down;
    }

    public String getExitDesc(){
        StringBuffer sb = new StringBuffer();
        if (northExit != null)
            sb.append("north ");
        if (eastExit != null)
            sb.append("east ");
        if (southExit != null)
            sb.append("south ");
        if (westExit != null)
            sb.append("west ");
        if (northwestExit != null)
            sb.append("northwest ");
        if (northeastExit != null)
            sb.append("northeast ");
        if (southeastExit != null)
            sb.append("southeast ");
        if (southwestExit != null)
            sb.append("southwest ");
        if (upExit != null)
            sb.append("up");
        if (downExit != null)
            sb.append("down");
        return sb.toString();
    }

    public Room getExit(String direction){
        Room ret = null;
        if (direction.equals("north")) {
            ret = northExit;
        }
        if (direction.equals("east")) {
            ret = eastExit;
        }
        if (direction.equals("south")) {
            ret = southExit;
        }
        if (direction.equals("west")) {
            ret = westExit;
        }
        if (direction.equals("northwest")) {
            ret = northwestExit;
        }
        if (direction.equals("northeast")) {
            ret = northeastExit;
        }
        if (direction.equals("southwest")) {
            ret = southwestExit;
        }
        if (direction.equals("southeast")) {
            ret = southeastExit;
        }
        if (direction.equals("up")) {
            ret = upExit;
        }
        if (direction.equals("down")) {
            ret = downExit;
        }
        return ret;
    }



    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public String toString()
    {
        return description;
    }

    public ArrayList<MonsterWolf> getMonsterWolves(){
        return monsterWolves;
    }

    public void ShowMonsterWolves(){
        for (MonsterWolf item:monsterWolves
             ) {
            System.out.println(item.getId()+" "+item.getHPValue());

        }
    }
    public void addmonsterwolves(MonsterWolf monsterWolf){
        monsterWolves.add(monsterWolf);
    }


}
